package com.example.administrator.idocment.docment;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.MediaStore;

import com.example.administrator.idocment.BaseTypeFind;
import com.example.administrator.idocment.msgpack.modelpack.AudioModel;
import com.example.administrator.idocment.tooltime.TimerFactory;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/7/15 0015.
 */
public class AudioFind  extends BaseTypeFind<AudioModel>
{
    public static  final String[] volumType=new String[]{"audio/x-mpegurl","audio/mp4a-latm","audio/x-mpeg","audio/mpeg","audio/ogg","audio/x-wav","audio/x-ms-wma"};

    public AudioFind(Context context) {
        super(context);
    }
    List<AudioModel> modelList=new ArrayList<>();
    @Override
    public void select() {
        Uri uri= MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
        String[] colum=new String[]{MediaStore.Audio.Media.DATA,MediaStore.Audio.Media.DISPLAY_NAME,MediaStore.Audio.Media.SIZE};
        String sort=MediaStore.Audio.Media.SIZE+" DESC";
        Cursor cursor=contentResolver.query(uri,colum,null,null,sort);
        cursor.moveToFirst();
        do {
         String path=cursor.getString(0);
            String title=cursor.getString(1);
            File file=new File(path);
         String date= TimerFactory.create(TimerFactory.YearFormat).paseTimer(file.lastModified());
         String size=getFileSzie(cursor.getLong(2));
         AudioModel audioModel=new AudioModel();
         audioModel.setPath(path);
         audioModel.setDate(date);
         audioModel.setSize(size);
         audioModel.setTitle(title);
         modelList.add(audioModel);
        }while (cursor.moveToNext());
        cursor.close();

    }

    @Override
    public List<AudioModel> getListInfo() {
        return modelList;
    }




}
